﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Httlgd.DataCenter.Services.Core;
using Httlgd.DataCenter.Services.Core.Common.Service;

using Httlgd.DataCenter.Services.Sms.BusinessComponent;
using Httlgd.DataCenter.Services.Sms.DataTransferObject;

namespace Httlgd.DataCenter.Services.Sms.ServiceLibrary
{
    public class GeneralDataService : IGeneralDataService
    {
        #region IGeneralDataService Implementation
        #region Speaker
        public DataTransferObject.SpeakerDTO SaveSpeaker(DataTransferObject.SpeakerDTO speaker)
        {
            SpeakerBC bc = new SpeakerBC();
            return BusinessService.Execute<SpeakerDTO, SpeakerDTO>(speaker, bc.Save);
        }

        public DataTransferObject.SpeakerDTO GetSpeakerByID(int id)
        {
            SpeakerBC bc = new SpeakerBC();
            return BusinessService.Execute<DTOKey, SpeakerDTO>(new DTOKey(id), bc.Retrieve);
        }

        public void DeleteSpeaker(int id)
        {
            //SpeakerBC bc = new SpeakerBC();
            //BusinessService.Execute<DTOKey>(new DTOKey(id), bc.Delete);
        }

        public DataTransferObjectCollectionBase<SpeakerDTO> GetAllSpeaker()
        {
            SpeakerBC bc = new SpeakerBC();
            return BusinessService.Execute<DataTransferObjectCollectionBase<SpeakerDTO>>(bc.RetrieveList);
        }
        #endregion

        #region Speaker Prefix

        public SpeakerPrefixDTO SaveSpeakerPrefix(SpeakerPrefixDTO speakerPrefix)
        {
            SpeakerPrefixBC bc = new SpeakerPrefixBC();
            return BusinessService.Execute<SpeakerPrefixDTO, SpeakerPrefixDTO>(speakerPrefix, bc.Save);
        }

        public SpeakerPrefixDTO GetSpeakerPrefixByID(int id)
        {
            SpeakerPrefixBC bc = new SpeakerPrefixBC();
            return BusinessService.Execute<DTOKey, SpeakerPrefixDTO>(new DTOKey(id), bc.Retrieve);
        }

        public void DeleteSpeakerPrefix(int id)
        {
            SpeakerPrefixBC bc = new SpeakerPrefixBC();
            BusinessService.Execute<DTOKey>(new DTOKey(id), bc.Delete);
        }

        public DataTransferObjectCollectionBase<SpeakerPrefixDTO> GetAllSpeakerPrefix()
        {
            SpeakerPrefixBC bc = new SpeakerPrefixBC();
            return BusinessService.Execute<DataTransferObjectCollectionBase<SpeakerPrefixDTO>>(bc.RetrieveList);
        }
        #endregion

        #region ServiceType
        public ServiceTypeDTO SaveServiceType(ServiceTypeDTO serviceType)
        {
            ServiceTypeBC bc = new ServiceTypeBC();
            return BusinessService.Execute<ServiceTypeDTO, ServiceTypeDTO>(serviceType, bc.Save);
        }

        public ServiceTypeDTO GetServiceTypeByID(int id)
        {
            ServiceTypeBC bc = new ServiceTypeBC();
            return BusinessService.Execute<DTOKey, ServiceTypeDTO>(new DTOKey(id), bc.Retrieve);
        }

        public void DeleteServiceType(int id)
        {
            ServiceTypeBC bc = new ServiceTypeBC();
            BusinessService.Execute<DTOKey>(new DTOKey(id), bc.Delete);
        }

        public DataTransferObjectCollectionBase<ServiceTypeDTO> GetAllServiceType()
        {
            ServiceTypeBC bc = new ServiceTypeBC();
            return BusinessService.Execute<DataTransferObjectCollectionBase<ServiceTypeDTO>>(bc.RetrieveList);
        }
        #endregion
        
        #region SermonCategory
        public SermonCategoryDTO SaveSermonCategory(SermonCategoryDTO sermonCategory)
        {
            SermonCategoryBC bc = new SermonCategoryBC();
            return BusinessService.Execute<SermonCategoryDTO, SermonCategoryDTO>(sermonCategory, bc.Save);
        }

        public SermonCategoryDTO GetSermonCategoryByID(int id)
        {
            SermonCategoryBC bc = new SermonCategoryBC();
            return BusinessService.Execute<DTOKey, SermonCategoryDTO>(new DTOKey(id), bc.Retrieve);
        }

        public void DeleteSermonCategory(int id)
        {
            SermonCategoryBC bc = new SermonCategoryBC();
            BusinessService.Execute<DTOKey>(new DTOKey(id), bc.Delete);
        }

        public DataTransferObjectCollectionBase<SermonCategoryDTO> GetAllSermonCategory()
        {
            SermonCategoryBC bc = new SermonCategoryBC();
            return BusinessService.Execute<DataTransferObjectCollectionBase<SermonCategoryDTO>>(bc.RetrieveList);
        }
        #endregion
        #endregion
    }
}
